<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('字段详细设计')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-interface-add">
            <input type="hidden" id="id" name="id" th:value="${fieldInfo.id}">
            <div class="form-group">
                <label class="col-sm-3 control-label">字段描述：</label>
                <div class="col-sm-8">
                    <textarea name="fieldDescription" class="form-control">[[${fieldInfo.fieldDescription}]]</textarea>
                </div>
            </div>

            <div class="form-group" th:if="${pkFlag} == true">
                <label class="col-sm-3 control-label">PK类型：</label>
                <div class="col-sm-8">
                    <select name="designContent" class="form-control m-b" th:with="type=${@dict.getType('pkType')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${fieldInfo.designContent}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group" th:if="${fkFlag} == true">
                <label class="col-sm-3 control-label">FK类型：</label>
                <div class="col-sm-8">
                    <select name="designContent" class="form-control m-b" th:with="type=${@dict.getType('fkType')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${fieldInfo.designContent}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group" th:if="${enumFlag} == true">
                <label class="col-sm-3 control-label">枚举类型：</label>
                <div class="col-sm-8">
                    <select name="designContent" id="designContent" class="form-control select2-multiple" multiple>
                        <option th:each="dict : ${sysDictDatas}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group" th:if="${timeFlag} == true">
                <label class="col-sm-3 control-label">时间类型：</label>
                <div class="col-sm-8">
                    <select name="designContent" class="form-control m-b" th:with="type=${@dict.getType('timeType')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${fieldInfo.designContent}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group" th:if="${otherFlag} == true">
                <label class="col-sm-3 control-label">其它：</label>
                <div class="col-sm-8">
                    <select name="designContent" class="form-control m-b" th:with="type=${@dict.getType('otherType')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="${fieldInfo.designContent}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "table/table";
        $("#form-interface-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/updateFieldDesign", $('#form-interface-add').serialize());
            }
        }

        var designContent = [[${fieldInfo.designContent}]];
        var enumFlag = [[${enumFlag}]];
        if (enumFlag && designContent) {
            $("#designContent").select2();
           var arr = designContent.split(",");
           // $("#designContent").select2("val", arr);
            $('#designContent').val(arr).trigger("change");
        }
    </script>
</body>
</html>